package com.zhou.combine.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * TestController
 *
 * @author zhouxianfeng
 * @date 2021-1-6
 */
@RestController
public class TestController {

    @Autowired
    private PasswordEncoder passwordEncoder;

    @Autowired
    private MenuMappingHandler menuMappingHandler;

    @PreAuthorize("hasRole('admin')")
    @GetMapping("/test")
    public String test(){
        return passwordEncoder.encode("123456");
    }

    @RequestMapping("/")
    public String test1(){
        return passwordEncoder.encode("123456");
    }

    @RequestMapping("/test/{name}")
    public String test1(String name){
        return name;
    }
    @RequestMapping("/test2")
    public String test2(){
        return "test2";
    }
    @RequestMapping("/test3/{name}")
    public String test3(String name){
        return name;
    }

}
